<?php
// feedbacks details list page
require_once 'view/adm/content/feedback.view.php';


class FeedbackViewPage extends PageController {

	var $form;

    function FeedbackViewPage() {
        parent::PageController();

        $this->form =& new FormController();
        $this->form->addChild('delete', new ButtonController(new Delegate($this, 'delete')));
        $this->form->addChild('feedbacks', new ButtonController(new Delegate($this, 'clean')));
        $this->form->setDefaultChild('feedbacks');

        $this->registerOnLoadListener(new Delegate($this, 'load'));
        //$this->registerOnActivateListener(new Delegate($this, 'check'));


        $this->addChild('FeedbackForm', $this->form);
        $this->setDefaultChild('FeedbackForm');


        $this->setDefaultView(new Handle('FeedbackFieldsView', array('/adm/content/feedback.view.page.html')));

        $this->addView('success', WACT_DEFAULT_VIEW);
        $this->addView('notfound', WACT_DEFAULT_VIEW);
        $this->addView('delete', new Handle('RedirectView', array('/delete')));
        $this->addView('index', new Handle('RedirectView', array('/')));
    }

     function delete(&$source, &$request, &$responseModel) {
	 	return 'delete';
	 }

     function load(&$source, &$request, &$responseModel) {
     	$submission_id = $request->getParameter('submission_id');
     	//print 'submission_id ='.$submission_id;

     	if ($submission_id) {
        	$record =& SubmissionForm::getRecord($submission_id);
        	//print_r( $record );
        	if (is_null($record)) {
            	return 'notfound';
        	}
            $responseModel->import($record->export());
        }
        //$responseModel->set('user_show','Running load');
     }

     function check(&$source, &$request, &$responseModel) {
     		//return 'success';
     		if  (!$request->hasPostProperty('submission_id')) return 'notfound';
     		else return 'success';
     }

     // redirect to list of all feedbacks
     function clean(&$source, &$request, &$responseModel) {
     	return 'index';
     }
}

?>